package com.ph.shopping.facade.member.service.dbservice.facade.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ph.shopping.common.util.container.ParamVerifyUtil;
import com.ph.shopping.common.util.result.Result;
import com.ph.shopping.facade.duboresult.DubboResult;
import com.ph.shopping.facade.mapper.MemberIntegralMapper;
import com.ph.shopping.facade.member.dto.MemberIntegralDto;
import com.ph.shopping.facade.member.service.dbservice.facade.IMemberIntegralDbService;
import com.ph.shopping.facade.member.vo.MemberIntegralSourceVo;

/**
 * 
* @ClassName: MemberIntegralDbService  
* @Description: 会员积分数据操作服务
* @author tony  
* @date 2017年3月23日  
*
 */
@Service
public class MemberIntegralDbService implements IMemberIntegralDbService{

	/**
	 * 
	 */
	@Autowired
	private MemberIntegralMapper memberIntegralMapper;

	@Override
	public Result queryMemberIntegralInfoLsitByPage(MemberIntegralDto dto) {
		Result result = DubboResult.getDefResultByImpl();
		PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
		List<MemberIntegralDto> list = memberIntegralMapper.selectMemberIntegralListInfo(dto);
		PageInfo<MemberIntegralDto> page = new PageInfo<MemberIntegralDto>(list);
		result.setCount(page.getTotal());
		result.setData(page.getList());
		result = DubboResult.getResultBySuccess(result);
		return result;
	}

	@Override
	public Result queryMemberIntegralInfoList(MemberIntegralDto dto) {
		Result result = DubboResult.getDefResultByImpl();
		List<MemberIntegralDto> list = memberIntegralMapper.selectMemberIntegralListInfo(dto);
		if (ParamVerifyUtil.objIsNotNull(list)) {
			result.setCount(list.size());
			result.setData(list);
			result = DubboResult.getResultBySuccess(result);
		}
		return result;
	}

	@Override
	public Result queryMemberIntegralSource() {
		Result result = DubboResult.getDefResultByImpl();
		List<MemberIntegralSourceVo> list = memberIntegralMapper.selectMemberIntegralSource();
		if (ParamVerifyUtil.objIsNotNull(list)) {
			result.setCount(list.size());
			result.setData(list);
			result = DubboResult.getResultBySuccess(result);
		}
		return result;
	}

}
